package com.viettel.core.entities.cms;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Type;

import com.viettel.core.enumtype.UserStatus;

/**
 *  TABLE Users
 *  @author: ToanTM1
 *  @version: 2.1
 *  @since: 2.1
 */
@Entity
@Table(name = "USERS")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name = "SEQ_STORE", sequenceName = "USERS_SEQ", allocationSize = 1)
public class Users implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
	@Column(name = "ID")
//	@Index(name="USERS_ID_PK")
	private Integer id;

	/**
	 * TEN DAY DU
	 */
	@Basic
	@Column(name = "NAME", length = 100)
	private String name;

	/**
	 * TEN KHONG DAU
	 */
	@Basic
	@Column(name = "NAME_TEXT", length = 100)
	private String nameText;

	/**
	 * EMAIL
	 */
	@Basic
	@Column(name = "EMAIL", length = 50)
	private String email;
	
	/**
	 * PHONE
	 */
	@Basic
	@Column(name = "PHONE", length = 50)
	private String phone;
	
	/**
	 * GENDER
	 */
	@Basic
	@Column(name = "GENDER", columnDefinition = "NUMBER(1,0)")
	private Integer gender;
	
	/**
	 * AGE
	 */
	@Basic
	@Column(name = "AGE", columnDefinition = "NUMBER(3,0)")
	private Integer age;
	
	/**
	 * TRANG THAI
	 */
	@Basic
	@Column(name = "STATUS", columnDefinition = "NUMBER(1,0)", nullable = false)
	@Type(type = "com.viettel.core.enumtype.GenericEnumUserType", parameters = {
			@Parameter(name = "enumClass", value = "com.viettel.core.enumtype.UserStatus"),
			@Parameter(name = "identifierMethod", value = "getValue"),
			@Parameter(name = "valueOfMethod", value = "parseValue") })
	@Index(name="USERS_STATUSX")
	private UserStatus status;	
	
	
	/**
	 * TO BAO
	 */
	@ManyToOne(targetEntity = Media.class)
	@JoinColumn(name = "MEDIA_ID", referencedColumnName = "id")
	@ForeignKey(name = "USERS_MEDIA_FK")
	private Media media;

	
	/**
	 * TINH/TP
	 */
	@ManyToOne(targetEntity = Province.class)
	@JoinColumn(name = "PROVINCE_ID", referencedColumnName = "id")
	@ForeignKey(name = "USERS_PROVINCE_FK")
	private Province province;
	
	/**
	 * QUAN/HUYEM
	 */
	@ManyToOne(targetEntity = District.class)
	@JoinColumn(name = "DISTRICT_ID", referencedColumnName = "id")
	@ForeignKey(name = "USERS_DISTRICT_FK")
	private District district;
	
	/**
	 * PHUONG
	 */
	@ManyToOne(targetEntity = Ward.class)
	@JoinColumn(name = "WARD_ID", referencedColumnName = "id")
	@ForeignKey(name = "USERS_WARD_FK")
	private Ward ward;
	
	/**
	 * THOI GIAN TAO
	 */
	@Basic
	@Column(name = "CREATED_TIME", columnDefinition = "timestamp(9) default systimestamp", insertable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdTime;

	/**
	 * USER TAO
	 */
	@Basic
	@Column(name = "CREATED_USER", length = 100)
	private String createdUser;
	
	/**
	 * DIA CHI
	 */
	@Basic
	@Column(name = "ADDRESS", length = 200)
	private String address;
	
	/**
	 * NGHE
	 */
	@Basic
	@Column(name = "CAREER", length = 200)
	private String career;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNameText() {
		return nameText;
	}

	public void setNameText(String nameText) {
		this.nameText = nameText;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}


	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Media getMedia() {
		return media;
	}

	public void setMedia(Media media) {
		this.media = media;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public District getDistrict() {
		return district;
	}

	public void setDistrict(District district) {
		this.district = district;
	}

	public Ward getWard() {
		return ward;
	}

	public void setWard(Ward ward) {
		this.ward = ward;
	}

	public Province getProvince() {
		return province;
	}

	public void setProvince(Province province) {
		this.province = province;
	}

	public UserStatus getStatus() {
		return status;
	}

	public void setStatus(UserStatus status) {
		this.status = status;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public String getCreatedUser() {
		return createdUser;
	}

	public void setCreatedUser(String createdUser) {
		this.createdUser = createdUser;
	}

	public String getCareer() {
		return career;
	}

	public void setCareer(String career) {
		this.career = career;
	}	
	
}